Imports System.Data.SqlClient
Imports System
Imports System.Data
Imports System.Windows.Forms

Public Class FrmTekeningen

    Dim strGeselecteerdeBedrijven As String = ""
    Dim BedrID As Integer
    Dim TekeningID As Integer

    Private Sub TekeningenBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Validate()
        Me.TekeningenBindingSource.EndEdit()
        Me.TekeningenTableAdapter.Update(Me.DocRegData2DataSet.Tekeningen)

    End Sub

    Private Sub FrmTekeningen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DocRegData2DataSet.Bedrijven' table. You can move, or remove it, as needed.
        Me.BedrijvenTableAdapter.Fill(Me.DocRegData2DataSet.Bedrijven)
        'TODO: This line of code loads data into the 'DocRegData2DataSet.Tekeningen' table. You can move, or remove it, as needed.
        Dim Werknummer As String = My.Forms.FrmInlogscherm.CmbWerknummer.SelectedValue.ToString
        Me.TekeningenTableAdapter.FillBy(Me.DocRegData2DataSet.Tekeningen, Werknummer)

    End Sub

    Private Sub BtnBedrijven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBedrijven.Click
        Me.Visible = False
        My.Forms.Bedrijven.Show()

    End Sub

    Private Sub BtnTekeningenBedrijf_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTekeningenBedrijf.Click
        
        'Get your connection string (You've done this right)  
        Dim strconnectionstring As String = My.Settings.Docregdata2ConnectionString
        'Create your SqlConnection (Done)  
        Dim objconnection As New SqlConnection(strconnectionstring)
        'Create your SqlCommand (done)  
        Dim objcommand As New SqlCommand("GetInfoTekeningen5", objconnection)
        objcommand.CommandType = CommandType.StoredProcedure

        BedrID = Me.TekvanBedrijvenDataGridView.CurrentRow.Cells(0).Value
        Dim werknummer As String = My.Forms.FrmInlogscherm.CmbWerknummer.SelectedValue.ToString

        '**Set your command properties**  
        With objcommand
            .Parameters.AddWithValue("@BedrijvenID", BedrID)
            .Parameters.AddWithValue("@Werknummer", Werknummer)
        End With

        'Create a new SqlDataAdapter  
        Dim objdataAdapter As New SqlDataAdapter()

        'Set the SelectCommand property of our adapter  
        objdataAdapter.SelectCommand = objcommand

        'Create a new DataSet  
        Dim objdatasetTekeningen As New DataSet

        'Fill the DataSet using the SqlDataAdapter  
        objdataAdapter.Fill(objdatasetTekeningen, "Tekeningenbedrijven")

        Dim objbindingsource As New BindingSource
        objbindingsource.DataSource = objdatasetTekeningen.Tables("Tekeningenbedrijven")

        TekeningenDataGridView.AutoGenerateColumns = True
        TekeningenDataGridView.DataSource = objbindingsource


    End Sub

    Private Sub Btn_Invoer_tekeningen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Invoer_Tekeningen.Click
        Me.Visible = False
        My.Forms.FrmNieuweTekening.Visible = True

    End Sub


    Private Sub BtnAfsluiten_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Application.Exit()
    End Sub

    Private Sub BtnHoofdmenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHoofdmenu.Click
        Me.Visible = False
        My.Forms.FrmHoofdmenu.Visible = True

    End Sub
End Class
